#普通循环语句
n = 100
counter = 1
while counter <= n:
    counter += 1
 
print("1 : %d" % (n))

#while 循环使用 else 语句
count = 0
while count < 5:
   print (count, " 小于 5")
   count = count + 1
else:
   print (count, " 大于或等于 5")

#for 语句,遍历数组
languages = ["C", "C++", "Perl", "Python"] 
for x in languages:
    print (x)

#break 语句用于跳出当前循环体
sites = ["Baidu", "Google","Runoob","Taobao"]
for site in sites:
    if site == "Runoob":
        print("菜鸟教程!")
        break
    print("循环数据 " + site)
else:
    print("没有循环数据!")
print("完成循环!")
print("-------------------------------------------------------------------")

#range()函数，遍历数字序列
for i in range(5):
        print(i)

print("-------------------------------------------------------------------")
#range指定区间的值
for i in range(5,9) :
    print(i)

print("-------------------------------------------------------------------")
#range以指定数字开始并指定不同的增量(甚至可以是负数，有时这也叫做'步长'):
for i in range(0, 10, 3) :
    print(i)

print("-------------------------------------------------------------------")
for i in range(-10, -100, -30) :
    print(i)

#break和continue语句及循环中的else子句
for letter in 'Runoob':     # 第一个实例
   if letter == 'n':
      break
   print ('当前字母为 :', letter)
  
var = 10                    # 第二个实例
while var > 0:              
   print ('当期变量值为 :', var)
   var = var -1
   if var == 5:
      break
 
print ("Good bye!")  


print("-------------------------------------------------------------------")
#占位符
for letter in 'Runoob': 
    if letter == 'o':
        pass
        print ('执行 pass 块')
        print ('当前字母 :', letter)
print ("Good bye!")